<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>系统配置列表</title>
<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
<jsp:include page="/WEB-INF/jsp_lib/extjs.jsp" />

<jsp:include page="add.jsp" />
<jsp:include page="edit.jsp" />

<script type="text/javascript">
	var dataStore;

	Ext.onReady(function() {

		dataStore = Ext.create('Ext.data.Store', {
			fields : [ 'logo_file_id', 'name', 'backgroud_file_id','menu_position', 'kid' ],
			remoteSort : false,
			autoLoad : true,
			sorters : {
				property : 'field',
				direction : 'ASC'
			},
			proxy : {
				type : "ajax",
				url : "${path}/cp/system/list_ui.htm",
				reader : {
					type : 'json',
					rootProperty : 'list'
				}
			}
		}); //#dataStore

		var listGridPanel = Ext.create('Ext.grid.Panel', {
			title : '系统ui管理',
			tbar : [ {
				text : '新增',
				xtype : 'button',
				icon : jcapp.getIcon("add.png"),
				handler : function() {
					myAdd();
				}
			} ],
			store : dataStore,
			columns : [ {
				text : 'logoid',
				dataIndex : 'logo_file_id',
				flex : 1
			}, {
				text : 'logo名字',
				dataIndex : 'name',
				flex : 1
			}, {
				text : '背景图片id',
				dataIndex : 'backgroud_file_id',
				flex : 1
			}, {
				text : '左侧菜单位置',
				dataIndex : 'menu_position',
				flex : 1
			}, {
				xtype : "actioncolumn",
				align : "center",
				text : '操作',
				flex : 1,
				items : [ {
					xtype : 'button',
					tooltip : '编辑',
					icon : jcapp.getIcon("application_form_edit.png"),
					handler : function(grid, rowIndex, colIndex) {
						var rec = grid.getStore().getAt(rowIndex);
						//alert("编辑 " + rec.get('kid'));
						myEdit(rec.get('kid'));
					}
				}, {
					xtype : 'button',
					tooltip : '删除',
					icon : jcapp.getIcon("cross.png"),
					handler : function(grid, rowIndex, colIndex) {
						var rec = grid.getStore().getAt(rowIndex);
						myDel(rec.get('kid'));
					}
				}
				
				]

			} ]
		}); //#listGridPanel

		listGridPanel.render(Ext.getBody());

	});

	function myDel(kid) {
		Ext.Msg.confirm("提示:", "确定删除选定的记录?", function(e) {
			if (e == "yes") {
				Ext.Ajax.request({
					url : "${path}/cp/system/del_ui.htm?kid=" + kid,
					success : function(response) {
						var json = Ext.util.JSON.decode(response.responseText);
						Ext.Msg.alert("提示", json.tip.msg);
						dataStore.load();
					},
					failure : function(response) {
						Ext.Msg.alert("提示", "操作失败!");
					}
				});
			}//#if
		});
	}//#myEdit
</script>
</head>
<body>

</body>
</html>